﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using ClientModel;
using System.ComponentModel;
using LocalServerApp;

namespace Client
{
    /// <summary>
    /// Interaction logic for winForgottenClothes.xaml
    /// </summary>
    public partial class winForgottenClothes : Window
    {
        private ObservableCollection<Hanger> hangerCollection = new ObservableCollection<Hanger>();

        public winForgottenClothes()
        {
            InitializeComponent();

            List<Hanger> lstHangers =Service.getInstance().getForgottenClothes();
            
            if(lstHangers.Count>0)
            {
                foreach (Hanger h in lstHangers)
                {
                    hangerCollection.Add(h);
                }
            }
            else
            {
                lstvResults.Visibility = Visibility.Hidden;
                lblInfo.Visibility = Visibility.Visible;
            }

        }

        public ObservableCollection<Hanger> HangerCollection
        {
            get { return hangerCollection; }
        }

        private GridViewColumnHeader _CurSortCol = null;
        private ListSortDirection _CurAdorner = new ListSortDirection();

        private void OrderBy(object sender, RoutedEventArgs e)
        {
            GridViewColumnHeader column = sender as GridViewColumnHeader;
            String field = column.Tag as String;

            if (_CurSortCol != null)
            {
                lstvResults.Items.SortDescriptions.Clear();
            }

            ListSortDirection newDir = ListSortDirection.Ascending;
            if (_CurSortCol == column && _CurAdorner == newDir)
                newDir = ListSortDirection.Descending;

            _CurAdorner = newDir;
            _CurSortCol = column;

            lstvResults.Items.SortDescriptions.Add(new SortDescription(field, newDir));
        }


        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult=true;
        }
    }
}
